package io.复制;

import java.io.*;

public class Demo1 {
    public static void main(String[] args) throws IOException {
        File sourcefile=new File("D:\\test.txt");
        InputStream is=new FileInputStream(sourcefile);
        OutputStream os=new FileOutputStream("D:\\test3.txt");

        long time1=System.currentTimeMillis();

        int n=is.read();
        while(n!=-1){
            os.write(n);
            n=is.read();
        }

        /*byte[] buf=new byte[is.available()];
        int n=is.read(buf);
        while (n!=-1) {
            os.write(buf);
            os.flush();
            n=is.read();
        }
        */

        is.close();
        os.close();

        long time2=System.currentTimeMillis();
        System.out.println("复制数据完毕，花费时间为："+(time2-time1));
    }
}
